package com.example.common.utils;

import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;

import com.example.common.MyApplication;

/**
 * 导航栏
 */
public class NavigationBarUtils {

    /**
     * 是否是全面屏
     * @return
     */
    public static boolean isFullScreen() {
        int val = Settings.Global.getInt(MyApplication.sInstener.getContentResolver(), getFullScreenSettingName(), 0);
        return val != 0;

    }

    /**
     * 根据设备获取全面屏设置名称
     *
     * @return
     */
    public static String getFullScreenSettingName() {
        String brand = Build.BRAND;
        if (TextUtils.isEmpty(brand)) return "navigationbar_is_min";

        if (brand.equalsIgnoreCase("HUAWEI")) {
            return "navigationbar_is_min";
        } else if (brand.equalsIgnoreCase("XIAOMI")) {
            return "force_fsg_nav_bar";
        } else if (brand.equalsIgnoreCase("VIVO")) {
            return "navigation_gesture_on";
        } else if (brand.equalsIgnoreCase("OPPO")) {
            return "navigation_gesture_on";
        } else {
            return "navigationbar_is_min";
        }
    }

    /**
     * 获取导航栏高度
     *
     * @param context
     * @return
     */
    public static int getBottomHeight() {
        int resourceId = MyApplication.sInstener.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
//        logger.info("height = " + context.getResources().getDimensionPixelSize(resourceId));
        return MyApplication.sInstener.getResources().getDimensionPixelSize(resourceId);
    }

}
